package cn.fl.riskctrl.controller;

import cmm.mid.core.framework.page.DataResultVO;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.riskctrl.service.IChannelRatingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description: 风险控制客户基础信息表 控制层
 */
@Controller
@RequestMapping("/riskctrl/channelRating")
public class ChannelRatingController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(ChannelRatingController.class);

	@Autowired
    private IChannelRatingService channelRatingService;

	/**
     * 到百融列表页面
     */
    @RequestMapping(value = "/toBrcdListPage.do", method = { RequestMethod.GET})
    public ModelAndView toBrcdListPage(HttpServletRequest request, HttpServletResponse response) {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toChkListPage", "百融列表请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        String dataId = request.getParameter("dataId");
        String dataType=request.getParameter("dataType");
        ModelAndView view = new ModelAndView("riskctrl/channelrating/brcdList");
        BaseLogUtils.info(logger, "toListPage", "跳转到列表页面.", CurrentThreadContext.getCurrentUserName());
        DataResultVO dataResultVO = channelRatingService.getBrcdListReport(dataId,dataType);
        view.addObject("brcdListReport", dataResultVO.getData());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toChkListPage", "耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }
    /**
     * 到百融详细信息页面
     */
    @RequestMapping(value = "/toBrcdReportDetailPage.do", method = { RequestMethod.GET})
    public ModelAndView toBrcdReportDeatilPage(HttpServletRequest request, HttpServletResponse response) {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toBrcdReportDeatilPage", "百融详细报告请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        String reportNo = request.getParameter("reportNo");
        String brApplyId = request.getParameter("brApplyId");
        ModelAndView view = new ModelAndView("riskctrl/channelrating/brcdDetail");
        BaseLogUtils.info(logger, "toListPage", "跳转到详细页面.", CurrentThreadContext.getCurrentUserName());
        DataResultVO dataResultVO = channelRatingService.getBrApplyReportDetail(reportNo,brApplyId);
        view.addObject("brApplyVO", dataResultVO.getData());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toBrcdReportDeatilPage", "百融详细报告耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }

    /**
     * 到元素列表页面
     */
    @RequestMapping(value = "/toYsejdListPage.do", method = { RequestMethod.GET})
    public ModelAndView toYsejdListPage(HttpServletRequest request, HttpServletResponse response) {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toYsejdListPage", "元素列表请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        String dataId = request.getParameter("dataId");
        String dataType=request.getParameter("dataType");
        ModelAndView view = new ModelAndView("riskctrl/channelrating/ysejdList");
        BaseLogUtils.info(logger, "toListPage", "跳转到元素列表页面.", CurrentThreadContext.getCurrentUserName());
        DataResultVO dataResultVO = channelRatingService.getYsedjListReport(dataId,dataType);
        view.addObject("ysejdApplyVOList", dataResultVO.getData());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toYsejdListPage", "耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }
    /**
     * 到元素详细信息页面
     */
    @RequestMapping(value = "/toYsejdReportDetailPage.do", method = { RequestMethod.GET})
    public ModelAndView toYsejdReportDetailPage(HttpServletRequest request, HttpServletResponse response) {
        Long startTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toYsejdReportDetailPage", "元素详细报告请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName());
        String reportNo = request.getParameter("reportNo");
        String ysApplyId = request.getParameter("ysApplyId");
        ModelAndView view = new ModelAndView("riskctrl/channelrating/ysejdDetail");
        BaseLogUtils.info(logger, "toYsejdReportDetailPage", "跳转到元素详细页面.", CurrentThreadContext.getCurrentUserName());
        DataResultVO dataResultVO = channelRatingService.getYsejdApplyReportDetail(reportNo,ysApplyId);
        view.addObject("ysejdReportVO", dataResultVO.getData());
        Long endTm = System.currentTimeMillis();
        BaseLogUtils.info(logger, "toYsejdReportDetailPage", "元素详细报告耗时：" + (endTm-startTm), CurrentThreadContext.getCurrentUserName());
        return view;
    }

}

